import store from '@/store'
import AjaxPlugin from '../components/AjaxPlugin/AjaxPlugin'

export const Auth = {
  isLogIn () {
    return !!store.state.authToken
  },
  async logout () {
    store.commit('REMOVE_AUTH_TOKEN')
    return true
  }
}

export const ServerDate = {
  diff: 0,
  get () {
    return new Date(ServerDate.diff + new Date().getTime())
  },
  set (date) {
    ServerDate.diff = new Date(date).getTime() - new Date().getTime()
  }
}

export function isMobile () {
  return navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)
}
